﻿<util:BaseUserControl x:Class="CheckerWPF.UserControls.uclOptionCheckerWPF"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:conv="clr-namespace:CheckerWPF.Converters"
             xmlns:uctl="clr-namespace:CheckerWPF.UserControls"
             xmlns:util="clr-namespace:CheckerWPF.Utils"
             mc:Ignorable="d" 
             d:DesignHeight="60" d:DesignWidth="439">
    <!--Height="{Binding CheckerHeight}" Width="{Binding CheckerWidth}"-->

    <Grid Name="LayoutRoot">
        <Grid.Resources>
            <conv:OptionCheckerConverter x:Key="OptionCheckerConverter" />
            <conv:TestConverter x:Key="TestConverter" />

            <Style x:Key="RadioButtonStyleTogglerButtonTypeLeft" TargetType="RadioButton">
                <!--
                <Setter Property="FontFamily" Value="Arial" />
                <Setter Property="FontSize" Value="12" />
                <Setter Property="Background" Value="#FF448DCA"/>
                <Setter Property="Foreground" Value="#FF000000"/>
                <Setter Property="HorizontalContentAlignment" Value="Left"/>
                <Setter Property="VerticalContentAlignment" Value="Top"/>
                <Setter Property="Padding" Value="4,1,0,0"/>
                <Setter Property="BorderThickness" Value="1"/>
                <Setter Property="Height" Value="30" />
                <Setter Property="Cursor" Value="Hand"/>
                <Setter Property="BorderBrush">
                    <Setter.Value>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#FFA3AEB9" Offset="0"/>
                            <GradientStop Color="#FF8399A9" Offset="0.375"/>
                            <GradientStop Color="#FF718597" Offset="0.375"/>
                            <GradientStop Color="#FF617584" Offset="1"/>
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="RadioButton">
                            <Grid>
                                <VisualStateManager.VisualStateGroups>
                                    <VisualStateGroup x:Name="CommonStates">
                                        <VisualState x:Name="Normal"/>
                                        <VisualState x:Name="MouseOver">
                                            <Storyboard>
                                                <ColorAnimation Duration="0" To="Black" Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)" Storyboard.TargetName="border" d:IsOptimized="True"/>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Cursor)" Storyboard.TargetName="border">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <Cursor>Hand</Cursor>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Cursor)" Storyboard.TargetName="rectangle">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <Cursor>Hand</Cursor>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Pressed">
                                            <Storyboard>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Cursor)" Storyboard.TargetName="border">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <Cursor>Hand</Cursor>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Cursor)" Storyboard.TargetName="rectangle">
                                                    <DiscreteObjectKeyFrame KeyTime="0">
                                                        <DiscreteObjectKeyFrame.Value>
                                                            <Cursor>Hand</Cursor>
                                                        </DiscreteObjectKeyFrame.Value>
                                                    </DiscreteObjectKeyFrame>
                                                </ObjectAnimationUsingKeyFrames>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Disabled">
                                            <Storyboard>
                                                <DoubleAnimation Duration="0" To=".55" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="contentPresenter"/>
                                            </Storyboard>
                                        </VisualState>
                                    </VisualStateGroup>
                                    <VisualStateGroup x:Name="CheckStates">
                                        <VisualState x:Name="Checked">
                                            <Storyboard>
                                                <ColorAnimation Duration="0" To="#FFBFBFBF" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)" Storyboard.TargetName="rectangle" d:IsOptimized="True"/>
                                            </Storyboard>
                                        </VisualState>
                                        <VisualState x:Name="Unchecked"/>
                                        <VisualState x:Name="Indeterminate"/>
                                    </VisualStateGroup>
                                    <VisualStateGroup x:Name="FocusStates">
                                        <VisualState x:Name="Focused"/>
                                        <VisualState x:Name="Unfocused"/>
                                    </VisualStateGroup>
                                    <VisualStateGroup x:Name="ValidationStates">
                                        <VisualState x:Name="Valid"/>
                                        <VisualState x:Name="InvalidUnfocused"/>
                                        <VisualState x:Name="InvalidFocused"/>
                                    </VisualStateGroup>
                                </VisualStateManager.VisualStateGroups>
                                <Border x:Name="border" BorderThickness="1" CornerRadius="2,0,0,2" BorderBrush="#FFBFBFBF">
                                    <Grid>
                                        <Rectangle x:Name="rectangle" >
                                            <Rectangle.Fill>
                                                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                                    <GradientStop Color="White" Offset="0"/>
                                                    <GradientStop Color="#FFBFBFBF" Offset="1"/>
                                                </LinearGradientBrush>
                                            </Rectangle.Fill>
                                        </Rectangle>
                                        <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20,0,20,0"/>
                                    </Grid>
                                </Border>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                -->
            </Style>
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <!--<RowDefinition />
            <RowDefinition />-->
        </Grid.RowDefinitions>

        <Border Name="bckTest10" Grid.Row="0" Background="{Binding ElementName=radOption10, Path=IsChecked, Converter={StaticResource TestConverter}, FallbackValue=Violet}" />
        <Border Name="bckTest20" Grid.Row="1" Background="{Binding ElementName=radOption20, Path=IsChecked, Converter={StaticResource TestConverter}, FallbackValue=Violet}" />

        <uctl:MyRadioButton x:Name="radOption10" Grid.Row="0" Style="{StaticResource RadioButtonStyleTogglerButtonTypeLeft}"
                     HorizontalAlignment="Stretch" VerticalAlignment="Center" 
                     IsChecked="{Binding ElementName=chkOption, Path=IsChecked, Mode=TwoWay, Converter={StaticResource OptionCheckerConverter}, ConverterParameter=Y}" HorizontalContentAlignment="Left" />
        <uctl:MyRadioButton x:Name="radOption20" Grid.Row="1" Style="{StaticResource RadioButtonStyleTogglerButtonTypeLeft}"
                     HorizontalAlignment="Stretch" VerticalAlignment="Center" 
                     IsChecked="{Binding ElementName=chkOption, Path=IsChecked, Mode=TwoWay, Converter={StaticResource OptionCheckerConverter}, ConverterParameter=N}" />

        <!--<uctl:RadioButtonAligned x:Name="radOption1" Grid.Row="0" 
                     HorizontalAlignment="Stretch" VerticalAlignment="Center" 
                     CheckAlign="MiddleLeft"
                     OptionChecked="{Binding ElementName=chkOption, Path=IsChecked, Mode=TwoWay, Converter={StaticResource OptionCheckerConverter}, ConverterParameter=Y}" HorizontalContentAlignment="Left" />-->
        <!--<uctl:RadioButtonAligned x:Name="radOption2" Grid.Row="1" 
                     HorizontalAlignment="Stretch" VerticalAlignment="Center" 
                     CheckAlign="MiddleRight"
                     OptionChecked="{Binding ElementName=chkOption, Path=IsChecked, Mode=TwoWay, Converter={StaticResource OptionCheckerConverter}, ConverterParameter=N}" />-->

        <CheckBox Name="chkOption" Grid.Row="2" Content="{Binding CheckerText}" 
                  Visibility="Collapsed" Checked="chkOption_Checked"
                  HorizontalAlignment="Stretch" VerticalAlignment="Center" />
    </Grid>
</util:BaseUserControl>
